<?php
/*
 * curl方式实现异步调用php脚本
 */
function _curl($url, $data = null, $timeout = 1)
{
    $curl = curl_init();
    //调用doOther.php脚本执行一些其他操作
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    if ($timeout > 0) { //超时时间秒
        curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
    }
    $output = curl_exec($curl);
    $error = curl_errno($curl);
    curl_close($curl);
    if ($error) {
        return false;
    }
    return $output;
}

//这里的url是被调用脚本的url
$output = _curl('http://youjiephp.test.com/phpasync/do_other.php', null, 1);
echo '主脚本执行完成'.date('Y-m-d H:i:s');